//
//  HMVisitorViewController.swift
//  CZBKWB31
//
//  Created by Linkon Y on 16/8/9.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HMVisitorViewController: UIViewController {
    //判断用户是否登录
    var islogin : Bool = HMUserAccountViewModel.sharedTools.isLogin
    
    //访客View
    var  visitorView : HMVisitorView?
    override func loadView() {
        if islogin {
          view = tableView
        }else{
            setupVisitorView()
        }
    }
    //设置访客视图
    func setupVisitorView(){
        setupNav()
         visitorView  = HMVisitorView()
        //闭包实例化02
        visitorView?.closure = {
            //点击04
        self.loginClick()
        }
        view = visitorView
    }
    //设置导航
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action:"loginClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginClick")
    }
    //注册按钮
    //登录按钮
    func loginClick(){
        let oauthVc = HMOAuthViewController()
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    // MARK: - 增加TableView控件
    lazy var tableView: UITableView = UITableView()
    
}



